Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 2359 get section by lang #2410

Merged
merged 8 commits into from
Feb 4, 2024

Conversation

SumDonkuS
Copy link
Contributor

@SumDonkuS SumDonkuS commented Jan 13, 2024

Adding optional lang argument for get_section global function. Language code will be added to the filename if it is not the default language. Related issue here.

Sanity check:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

  • Are you doing the PR on the next branch?

If the change is a new feature or adding to/changing an existing one:

  • Have you created/updated the relevant documentation page(s)?

@SumDonkuS SumDonkuS changed the title Draft: Issue 2359 get section by lang Issue 2359 get section by lang Jan 13, 2024
@Keats
Copy link
Collaborator

Keats commented Jan 18, 2024

Thinking about it a bit more, we don't have it for get_page either... We should probably add it to both to be consistent and share the code when possible

@SumDonkuS
Copy link
Contributor Author

Good call on adding it to get_page as well. I have that added the code and tried to generalize as much code across to be used by both as possible. Please let me know what you think.

@SumDonkuS SumDonkuS requested a review from Keats January 20, 2024 16:32
}
}

fn calculate_path<'a>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure calculate_path is the right name. get_path_with_lang? Not sure

@@ -154,6 +160,12 @@ If you only need the metadata of the section, you can pass `metadata_only=true`
{% set section = get_section(path="blog/_index.md", metadata_only=true) %}
```

If selecting a specific language for the section, you can pass `lang` with the language code to the function:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would mention for pages and here that it's equivalent to {% set section = get_section(path="blog/_index.fr.md") %}

…. Modify documentation for get_section and get_page to include equivalent calls without using lang argument to demostrate how lang argument effects pathing.
@SumDonkuS
Copy link
Contributor Author

Great. Changed the function name to be more specific, like you suggested. Also, added to the docs equivalencies based on if the language passed is the default language or not.

@SumDonkuS SumDonkuS requested a review from Keats January 27, 2024 17:42
@Keats Keats merged commit 73e06bd into getzola:next Feb 4, 2024
5 checks passed
@Keats
Copy link
Collaborator

Keats commented Feb 4, 2024

Thanks!

veluca93 pushed a commit to veluca93/zola that referenced this pull request May 14, 2024
* adding optional `lang` arugment to `get_section` global function

* Add handling of default language passed in `lang` argument of `get_section`

* Remove clones for path.  Change "?" to an explicit check for error

* lint changes

* Clean up error handling for add_lang_to_path call

* fix format

* Add optional parameter "lang" to get_page template function.  Add check for language available in config.

* Modify helper function name from calculate_path to get_path_with_lang.  Modify documentation for get_section and get_page to include equivalent calls without using lang argument to demostrate how lang argument effects pathing.
Keats pushed a commit that referenced this pull request Jun 20, 2024
* adding optional `lang` arugment to `get_section` global function

* Add handling of default language passed in `lang` argument of `get_section`

* Remove clones for path.  Change "?" to an explicit check for error

* lint changes

* Clean up error handling for add_lang_to_path call

* fix format

* Add optional parameter "lang" to get_page template function.  Add check for language available in config.

* Modify helper function name from calculate_path to get_path_with_lang.  Modify documentation for get_section and get_page to include equivalent calls without using lang argument to demostrate how lang argument effects pathing.
berdandy pushed a commit to berdandy/azola that referenced this pull request Sep 17, 2024
* adding optional `lang` arugment to `get_section` global function

* Add handling of default language passed in `lang` argument of `get_section`

* Remove clones for path.  Change "?" to an explicit check for error

* lint changes

* Clean up error handling for add_lang_to_path call

* fix format

* Add optional parameter "lang" to get_page template function.  Add check for language available in config.

* Modify helper function name from calculate_path to get_path_with_lang.  Modify documentation for get_section and get_page to include equivalent calls without using lang argument to demostrate how lang argument effects pathing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants